const { DoublyLinkedList } = require('./doubly-linked-list');

class StackLinkedList {
  constructor() {
    this.items = new DoublyLinkedList();
  }

  size() {
    return this.items.size();
  }

  push(item) {
    if (this.size() === 0) {
      this.items.insert(item, 0);
    }
    this.items.push(item);
  }

  pop() {
    if (this.size() === 0) {
      return undefined;
    }
    return this.items.removeAt(this.size() - 1);
  }
}

exports.StackLinkedList = StackLinkedList;
